﻿@model List<XukaShop.Models.Entities.Brand>

@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
    
}

@section Breadcrumbs
{
    <div class="media">
        <div class="pageicon pull-left">
            <i class="fa fa-home"></i>
        </div>
        <div class="media-body">
            <ul class="breadcrumb">
                <li><a href="@Url.Action("Index", "Dashboard")"><i class="glyphicon glyphicon-home"></i></a></li>
                <li><a href="@Url.Action("Index", "Dashboard")">Trang chủ</a></li>
            </ul>
            <h4>Nhãn hàng</h4>
        </div>
    </div>
}

@section MenuBar
{
    <h5 class="leftpanel-title">Menu</h5>
    <ul class="nav nav-pills nav-stacked">
        <li><a href="@Url.Action("Index", "Dashboard")"><i class="fa fa-home"></i><span>Trang chủ</span></a></li>
        <li><a href="@Url.Action("Index", "Order")"><i class="glyphicon glyphicon-shopping-cart"></i><span class="pull-right badge">5</span><span>Đặt hàng</span></a></li>
        <li><a href="@Url.Action("Index", "Message")"><i class="glyphicon glyphicon-envelope"></i><span class="pull-right badge">5</span><span>Tin nhắn</span></a></li>
        <li class="parent active"><a href="#"><i class="fa fa-file-text"></i><span>Sản phẩm</span></a>
            <ul class="children">
                <li><a href="@Url.Action("ProductList", "Product")">Tất cả sản phẩm</a></li>
                <li><a href="@Url.Action("NewProduct", "Product")">Sản phẩm mới</a></li>
                <li><a href="@Url.Action("CommingSoonProduct", "Product")">Sản phẩm sắp có</a></li>
                <li class="active"><a href="@Url.Action("Index", "Brand")">Nhãn hàng</a></li>
            </ul>
        </li>
        <li><a href="@Url.Action("Index", "Promotion")"><i class="glyphicon glyphicon-bullhorn"></i><span>Giảm giá</span></a></li>
        <li><a href="@Url.Action("MemberList", "Member")"><i class="glyphicon glyphicon-user"></i><span>Thành viên</span></a></li>
        <li class="parent"><a href="#"><i class="fa fa-file-text"></i><span>Quản lý chung</span></a>
            <ul class="children">
                <li><a href="@Url.Action("Index", "Banner")">Banners</a></li>
            </ul>
        </li>
    </ul>
}

<div class="panel panel-default-head">
    <div class="panel-heading">
        <h4 class="panel-title">Danh sách nhãn hàng</h4>
        <p>Bấm nút "Tạo mới" để tạo mới nhãn hàng.<span style="margin-left: 65%">@Html.ActionLink("Tạo mới", "BrandDetail", "Brand", null, new { @class = "btn btn-danger btn-rounded" })</span></p>

    </div>
    <!-- panel-heading -->

    <div id="lstBrandProduct">
        @Html.Partial("_BrandList", Model);
    </div>
</div>


<script>
    function deleteBrand(brandId) {
        bootbox.confirm("Bạn có muốn xóa nhãn hàng này không?", function (result) {
            if (result) {
                $.ajax({
                    url: "@Url.Action("DeleteBrand", "Brand")",
                    type: "POST",
                    data: { brandId: brandId },
                    success: function (result) {
                        if (result == "@XukaShop.Common.CommonConst.SUCCESSFUL") {
                            $('.close').click();
                            reloadTable();
                            showMessageDeleteSuccess();
                        }
                        if (result == "@XukaShop.Common.CommonConst.FAIL") {
                            $('.close').click();
                            showMessageDeleteFail();
                        }
                    }
                });
            }
        });
    }

    function showMessageDeleteSuccess() {
        jQuery.gritter.add({
            title: 'Thành công!',
            text: 'Xóa nhãn hàng sản phẩm thành công!',
            class_name: 'growl-success',
            sticky: false,
            time: '1000'
        });
        return false;
    }

    function showMessageDeleteFail() {
        jQuery.gritter.add({
            title: 'Thất bại!',
            text: 'Xóa nhãn hàng sản phẩm thất bại!',
            class_name: 'growl-danger',
            sticky: false,
            time: '1000'
        });
        return false;
    }

    

</script>
